Remove deprecated CDN customisation options#6326
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
…tions # Conflicts: # stream-chat-android-compose/api/stream-chat-android-compose.api
WalkthroughThis refactoring removes deprecated customization hooks for file downloads, image headers, asset transformation, and document viewing across the Stream Chat Android SDK. The changes consolidate attachment download and image loading behavior to rely exclusively on CDN configuration via Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/handler/DocumentAttachmentPreviewHandler.kt (1)
27-48: Centralize the document MIME matcher withAttachmentDestination.This class and
AttachmentDestination.docMimeTypenow gate the same downstream handler, but they keep separate allowlists and already differ in how they match vendor types. A shared helper would keep preview and navigation behavior from drifting.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/handler/DocumentAttachmentPreviewHandler.kt` around lines 27 - 48, DocumentAttachmentPreviewHandler currently constructs its own allowlist and vendor-type check which diverges from AttachmentDestination.docMimeType; replace the duplicated logic by delegating MIME checks to the centralized helper used by navigation (either call AttachmentDestination.docMimeType if it's a function or refactor AttachmentDestination to expose a shared isDocMimeType(mimeType: String?) helper), then update DocumentAttachmentPreviewHandler.canHandle to return false for null/empty assetUrl and call that shared helper for mimeType matching so preview and destination behavior remain identical (keep reference to DocumentAttachmentPreviewHandler.canHandle and AttachmentDestination.docMimeType/isDocMimeType in the change).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/state/ChatClientStateExtensions.kt`:
- Around line 327-330: Check for a valid downloadable URL before calling
Uri.parse: if both attachment.assetUrl and attachment.imageUrl are null or
blank, immediately return a Result.Failure (or the function's error result)
instead of proceeding to Uri.parse(...) and DownloadManager logic; update the
block that currently creates downloadManager/uri/subPath (reference
attachment.assetUrl, attachment.imageUrl, Uri.parse) to perform this guard-first
check so malformed attachments fail fast and avoid exception-driven control
flow.
- Around line 307-315: Update the KDoc for the download attachment method to
state that the CDN interface (CDN.imageRequest and CDN.fileRequest) only
transforms URL and headers and does not apply any customizations made via
interceptRequest to other DownloadManager.Request properties (e.g., destination,
visibility, network constraints); mention the ChatClient and CDN symbols and
call out interceptRequest and DownloadManager.Request explicitly and add a note
referencing the v7 migration guide so developers know those interceptRequest
behaviors are not preserved and must be handled differently during migration.
In `@stream-chat-android-compose/api/stream-chat-android-compose.api`:
- Around line 670-675: The public opt-in for CDN-aware document previews was
removed; restore a public boolean overload (with default true) on
defaultAttachmentHandlers(Context) named defaultAttachmentHandlers(Context,
useDocumentGView: Boolean) and add a public constructor overload on
DocumentAttachmentPreviewHandler(Context, useDocumentGView: Boolean) that
preserves the existing default of true so consumers can opt-out by passing
false; ensure these symbols (defaultAttachmentHandlers and
DocumentAttachmentPreviewHandler) are exposed in the API dump and regenerate the
API file so callers can still call
AttachmentPreviewHandler.defaultAttachmentHandlers(context, false) or new
DocumentAttachmentPreviewHandler(context, false) to opt out of useDocumentGView.
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/handler/AttachmentPreviewHandler.kt`:
- Around line 48-52: The defaultAttachmentHandlers factory removed the
useDocumentGView opt-in and hard-coded DocumentAttachmentPreviewHandler,
preventing callers from passing useDocumentGView=false; restore the function
signature public fun defaultAttachmentHandlers(context: Context,
useDocumentGView: Boolean = true) and update its implementation to conditionally
include DocumentAttachmentPreviewHandler(context) (or the legacy
DocumentPreviewHandler when useDocumentGView is false) based on that flag so the
default remains true but callers can opt out; update references to
defaultAttachmentHandlers to compile with the restored parameter if needed.
---
Nitpick comments:
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/handler/DocumentAttachmentPreviewHandler.kt`:
- Around line 27-48: DocumentAttachmentPreviewHandler currently constructs its
own allowlist and vendor-type check which diverges from
AttachmentDestination.docMimeType; replace the duplicated logic by delegating
MIME checks to the centralized helper used by navigation (either call
AttachmentDestination.docMimeType if it's a function or refactor
AttachmentDestination to expose a shared isDocMimeType(mimeType: String?)
helper), then update DocumentAttachmentPreviewHandler.canHandle to return false
for null/empty assetUrl and call that shared helper for mimeType matching so
preview and destination behavior remain identical (keep reference to
DocumentAttachmentPreviewHandler.canHandle and
AttachmentDestination.docMimeType/isDocMimeType in the change).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8bc8c622-3f3d-4034-bd1b-77a3c8a66038
📒 Files selected for processing (38)
stream-chat-android-client/api/stream-chat-android-client.apistream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/state/ChatClientStateExtensions.ktstream-chat-android-client/src/main/java/io/getstream/chat/android/client/di/ChatModule.ktstream-chat-android-compose/api/stream-chat-android-compose.apistream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/MediaAttachmentContent.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewActivity.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewContract.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/handler/AttachmentPreviewHandler.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/handler/DocumentAttachmentPreviewHandler.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/ChatTheme.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/ImageHeadersInterceptor.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/ImageUtils.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/util/AttachmentDownloadUtils.ktstream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewActivityTest.ktstream-chat-android-docs/src/main/java/io/getstream/chat/docs/java/ui/general/Configuration.javastream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/ui/general/Configuration.ktstream-chat-android-ui-common/api/stream-chat-android-ui-common.apistream-chat-android-ui-common/src/main/AndroidManifest.xmlstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/documents/AttachmentDocumentActivity.javastream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/AsyncImageHeadersProvider.ktstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/DownloadAttachmentUriGenerator.ktstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/DownloadRequestInterceptor.ktstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/ImageAssetTransformer.ktstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/ImageHeadersProvider.ktstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/VideoHeadersProvider.ktstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/images/internal/CoilStreamImageLoader.ktstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/images/internal/StreamImageLoader.ktstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/utils/extensions/Attachment.ktstream-chat-android-ui-common/src/main/res/layout/stream_activity_attachment_document.xmlstream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/documents/AttachmentDocumentActivityTest.ktstream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/utils/extensions/AttachmentExtensionsTest.ktstream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/utils/extensions/AttachmentExtensionsTests.ktstream-chat-android-ui-components/api/stream-chat-android-ui-components.apistream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/ChatUI.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/gallery/internal/AttachmentGalleryVideoPageFragment.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/MessageListView.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/navigation/destinations/AttachmentDestination.kt
💤 Files with no reviewable changes (25)
- stream-chat-android-docs/src/main/java/io/getstream/chat/docs/java/ui/general/Configuration.java
- stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewActivityTest.kt
- stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/utils/extensions/AttachmentExtensionsTest.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/DownloadRequestInterceptor.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/utils/extensions/Attachment.kt
- stream-chat-android-client/src/main/java/io/getstream/chat/android/client/di/ChatModule.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/AsyncImageHeadersProvider.kt
- stream-chat-android-ui-common/src/main/AndroidManifest.xml
- stream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/ui/general/Configuration.kt
- stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/utils/extensions/AttachmentExtensionsTests.kt
- stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewActivity.kt
- stream-chat-android-ui-common/src/main/res/layout/stream_activity_attachment_document.xml
- stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/ImageHeadersInterceptor.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/ImageHeadersProvider.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/images/internal/StreamImageLoader.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/VideoHeadersProvider.kt
- stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/MediaAttachmentContent.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/ImageAssetTransformer.kt
- stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewContract.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/DownloadAttachmentUriGenerator.kt
- stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/documents/AttachmentDocumentActivity.java
- stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt
- stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/documents/AttachmentDocumentActivityTest.kt
- stream-chat-android-ui-common/api/stream-chat-android-ui-common.api
- stream-chat-android-ui-components/api/stream-chat-android-ui-components.api
...client/src/main/java/io/getstream/chat/android/client/api/state/ChatClientStateExtensions.kt
Show resolved
Hide resolved
...client/src/main/java/io/getstream/chat/android/client/api/state/ChatClientStateExtensions.kt
Show resolved
Hide resolved
...io/getstream/chat/android/compose/ui/attachments/preview/handler/AttachmentPreviewHandler.kt
Show resolved
Hide resolved
…tions # Conflicts: # stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/navigation/destinations/AttachmentDestination.kt
|


Goal
Remove deprecated CDN customization APIs that were superseded by the
CDNinterface introduced in #6295. These APIs have been deprecated and marked for removal, with clear migration paths documented in the deprecation notices.The
CDNinterface provides a unified, more powerful approach to customizing file/image URLs and headers across the SDK, replacing the fragmented legacy APIs.DOCS: https://github.com/GetStream/docs-content/pull/1142
Implementation
Removed from
ChatClient.Builder:shareFileDownloadRequestInterceptor(Interceptor)- replaced bycdn(CDN)configurationRemoved from
ChatClientextension:downloadAttachmentparameters:generateDownloadUriandinterceptRequest- CDN transformations are now applied automatically via the configuredCDNimplementationRemoved from Compose UI components:
DownloadAttachmentUriGeneratorparameter fromMediaGalleryPreviewActivity,MediaGalleryPreviewContract.Input, and related componentsDownloadRequestInterceptorparameter from the same componentsAttachmentPreviewHandler.defaultAttachmentHandlers()to no longer accept deprecated parametersDocumentAttachmentPreviewHandlerconstructorInternal cleanup:
shareFileDownloadRequestInterceptorfromChatModuleconstructorTesting
Summary by CodeRabbit